package net.aiform.template.service.impl;

import java.util.List;

import net.aiform.template.dao.TemplateDao;
import net.aiform.template.pojo.Template;
import net.aiform.template.service.TemplateService;
import ext.cjt.CommonMethods;

public class TemplateServiceImpl implements TemplateService {
	TemplateDao templateDao;

	@Override
	public Template getNewTemplate() {
		Template t = new Template();
		String id = CommonMethods.getUUID();
		t.setCode(id);
		t.setValueTable(CommonMethods.getRandom(1001, 1002) + "");
		return t;
	}

	@Override
	public void save(Template template) {
		templateDao.save(template);
	}

	public TemplateDao getTemplateDao() {
		return templateDao;
	}

	public void setTemplateDao(TemplateDao templateDao) {
		this.templateDao = templateDao;
	}

	@Override
	public List<Template> findAll() {
		return this.templateDao.findAll();
	}

	@Override
	public Template get(String code) {
		return this.templateDao.get(code);
	}

	@Override
	public Template get(Integer id) {
		return this.templateDao.get(id);
	}

}
